<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>个人存款计算器</title>
		<link rel="shortcut icon" type="image/x-icon" href="img/logo.png"/>
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
		<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
		<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<script src="js/jquery.min.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="css/bootstrap.min.css"/>
		<script>
			function calc(){
				// alert("吃啥？")
				// confirm("确认吃嘛")
				money = $("#money").val();
				reg = /^[0-9]{1,8}$/
				if(!reg.test(money)){
					$("#money").css("border-color","red")
					return;
				}else{
					$("#money").css("border-color","")
				}
				moneyNum = parseInt(money);
				
				year = $("#year option:selected").text();
				if (year == "一年"){
					balance = 0.0175 * moneyNum * 1;
					total = balance + moneyNum;
				}
				if (year == "二年"){
					balance = 0.0225 * moneyNum * 2;
					total = balance + moneyNum;
				}
				if (year == "三年"){
					balance = 0.0275 * moneyNum * 3;
					total = balance + moneyNum;
				}
				if (year == "四年"){
					balance = 0.0275 * moneyNum * 4;
					total = balance + moneyNum;
				}
				if (year == "三年"){
					balance = 0.0275 * moneyNum * 3;
					total = balance + moneyNum;
				}
				if (year == "五年"){
					balance = 0.0275 * moneyNum * 5;
					total = balance + moneyNum;
				}
				$("#balance").val(balance);
				$("#total").val(total);
			}
		</script>


	</head>
	<body>
		<div class="text-center center-block" style="width: 50%;">
		<div>
			<img src="./img/cmb.png" style="width: 200px; ">
		</div>
		<table class="table table-bordered">
			<tr class="bg-primary">
				<td colspan="2">个人存款计算器</td>
			</tr>
			<tr>
				<td>存款金额</td>
				<td>
					<input class="form-control" placeholder="请输入存款金额" type="text" id="money" />
				</td>
			</tr>
			<tr>
				<td>存款期限</td>
				<td>
					<select id="year" class="form-control">
						<option value="0.0175">一年</option>
						<option value="0.0225">二年</option>
						<option value="0.0275">三年</option>
						<option value="0.0275">五年</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>所得利息</td>
				<td><input class="form-control" type="text" readonly="readonly" id="balance" /></td>
			</tr>
			<tr>
				<td>本息合计</td>
				<td><input class="form-control" type="text" readonly="readonly" id="total" /></td>
			</tr>
			<tr>
				<td colspan="2">
					<button onclick="calc()" class="btn btn-danger btn-block" type="button">开始计算</button>
				</td>
			</tr>
		</table>
		开发者：192056322冷奇松
		</div>
	</body>
</html>
